home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
netmail
/
wsomr120.zip
/
WS.DAT
/
TELIX.SLT
< prev
next >
Wrap
Text File
|
1996-04-24
|
4KB
|
188 lines
// =====================================================
// Telix Script for down/uploading of Internet mails
// By Frank Wang
// =====================================================
// -- Replace following entries with yours - //
str dial_array[] = "1 2 3 4 5"; // Entries in the directory
str login_name[] = "wang"; // login name
str password[] = "######"; // your password
str host_prompt[] = "durian.usc.edu.ph>"; // change this if your host is diff
str in_file[] = "inet.001"; // incoming mail
str out_file[] = "inet.txt"; // outgoing mail
str log_file[] = "inet.log"; // log file
// following two entries almost the same in the Internet
str login_pmt[] = "login:";
str pswrd_pmt[] = "Password:";
// a possible change is in connect() function
// **** End of parameter area *** //
int max_try = 99;
int nstart = 0;
int nattemp_sec = 0;
int nonline = 0;
str log_str[80];
str upload_file[80];
main()
{
int ret, is_upload, t;
nstart = curtime();
copystr( _up_dir, upload_file, 0, strlen(_up_dir) );
strcat( upload_file, out_file );
hello();
is_upload = check_replies();
t = timer_start(0);
ret = connected();
nattemp_sec = timer_total(t);
if ( ret )
{
timer_restart(t, 0);
if ( is_upload )
upload_replies();
run_unix_script();
nonline = timer_total(t);
quit_proc();
}
else
prints( "Connection failed..." );
update_log( ret );
status_wind( log_str, 50 );
exittelix( ret != 0, 1 );
}
hello()
{
clear_scr();
prints( "Connecting Internet..." );
}
// Try to connect to Internet, return non zero if connected
connected()
{
int ret, cnt;
ret = dial( dial_array, max_try );
cnt = 0;
if ( ret )
{
while ( cnt < 20 )
{
if ( waitfor( login_pmt, 1 ) )
break;
cputc( 13 );
cnt = cnt + 1;
}
cput_line( login_name );
waitfor( pswrd_pmt );
cput_line( password );
// waitfor ( "Press Enter to continue..." );
// cputc( 13 );
waitfor ( host_prompt );
}
return ret;
}
// Running xpost(Unix script) in Internet
run_unix_script()
{
cputs( "sh wpost " );
cputs( in_file );
cputs( " " );
cputs( out_file );
cputc( 13 );
waitfor ( "wpost done", 60*10 );
}
quit_proc()
{
cput_line ( "quit" );
if ( waitfor( "login:", 20 ) )
hangup();
else
prints( "carrier probably lost by this time, safe to quit" );
}
check_replies()
{
int ret = 0;
str buf[20];
if ( filefind(upload_file, 0, buf ) )
{
printsc( "<< Outgoing mail found " );
printsc( buf );
printsc( " size " );
printn( filesize( "" ) );
prints( " >>" );
ret = 1;
}
else
prints( "<< No outgoing mail found >> " );
return ret;
}
upload_replies()
{
str buf[16];
if ( filefind(upload_file, 0, buf) )
{
cputs( "rm " );
cputs( buf );
cputc( 13 );
cputs( "rz " );
cputs( buf );
cputc( 13 );
send( 'Z', upload_file );
fdelete( upload_file );
}
}
cput_line( str m )
{
cputs( m );
cputc( 13 );
}
update_log( int is_connected )
{
int f;
str temp[64];
date( nstart, temp );
strcat( log_str, temp );
strcat( log_str, " " );
time( nstart, temp );
strcat( log_str, temp );
strcat( log_str, " Connected:" );
if ( is_connected )
strcat( log_str, " OK" );
else
strcat( log_str, " NO" );
strcat( log_str, temp );
strcat( log_str, " Sec:" );
itos( nattemp_sec/10, temp );
strcat( log_str, temp );
strcat( log_str, " online time:" );
itos( nonline/10, temp );
strcat( log_str, temp );
f = fopen( log_file, "a" );
fputs( log_str, f );
fputc( 0x0d, f );
fputc( 0x0a, f );
fclose(f);
}